<?php

namespace app\api\service;

/*
 service 层统一 code=0的时候表示成功
*/
class CommonService
{
    public static function make()
    {
        return new static();
    }

    public function arrReturn($code, $data, $msg)
    {
        return ['code' => $code, 'data' => $data, 'msg' => $msg];
    }

    public function valiReturn($data = [], $code = 0, $msg = '')
    {
        return ['code' => $code, 'data' => $data, 'msg' => $msg];
    }

    public function inValiReturn($msg = '操作失败', $code = 500, $data = [])
    {
        return ['code' => $code, 'data' => $data, 'msg' => $msg];
    }

    /**
     * 强制返回.
     */
    public function forceReturn($data)
    {
        return $data;
    }
}
